﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using System.Data.SqlClient;

namespace FRM_Main
{
    public partial class FRM_Login : DevExpress.XtraEditors.XtraForm
    {
        public FRM_Login()
        {
            InitializeComponent();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
        //    try
        //    {

        //        if (txtTenDangNhap.Text == "" || txtMatKhau.Text == "")
        //        {
        //            MessageBox.Show("Dang nhap that bai");
        //            txtTenDangNhap.Focus();
        //            return;
        //        }
        //        else
        //        {
        //            string sqlconn = "Data Source=GODWAR;Initial Catalog=QuanTriHeThong;User ID=sa;Password=123456";
        //            SqlConnection conn = new SqlConnection(sqlconn);
        //            conn.Open();
        //            SqlCommand cmd = new SqlCommand("Select MatKhau from NGUOIDUNG where TenNguoiDung ='" + txtTenDangNhap.Text + "'", conn);
        //            SqlDataReader reader = cmd.ExecuteReader();
        //            reader.Read();
        //            if (txtMatKhau.Text == reader.GetValue(0).ToString())
        //            {
        //                MessageBox.Show("Dang Nhap thanh cong!");
        //                reader.Close();
        //                conn.Close();
        //                this.Hide();
                        FRM_Main f = new FRM_Main();
                        f.Sender1(txtTenDangNhap.Text);
                       f.Show();
        //                //FRM_Main form = new FRM_Main();
        //                //form.ShowDialog();

        //            }
        //            else
        //            {
        //                MessageBox.Show("Sai Mat Khau");
        //                txtMatKhau.Focus();
        //            }
        //            reader.Close();
        //            conn.Close();
        //        }
        //    }
        //    catch (SqlException)
        //    {
        //        MessageBox.Show("Ten dang nhap va mat khau khong hop le");
        //        txtTenDangNhap.Focus();
        //    }
        //    //FRM_Main f = new FRM_Main();
        //    //f.Show();
        //    //this.Hide();
        }

        private void btnKetThuc_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}